﻿package com.model 
{
	import com.element.Clips;
	import com.event.EventZheng;
	import com.staticInfo.EventConst;
	import com.utils.DebugTrace;
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.geom.Point;
	
	/**
	 * 存放main这个级别需要的信息
	 * @author zhengzihua
	 */
	public class MainData extends EventDispatcher
	{
		private var _loginStatus:Boolean = false;//用户是否处于登陆状态
		private var _isMyFarm:Boolean = true;//是否在自己的农场中
		private var _operate:String = "road";//用户当前操作
		private var _putObjType:String;//摆放在地图上物体的类型
		private var tempOperate:String = "";
		public function MainData() 
		{
			
		}
		
		private function onReadyed(e:EventZheng):void //等main将上一个操作的动作结束之后,再更改operate
		{
			DebugTrace.dtrace("code info MainData.as:上一个操作是:" + _operate);
			removeEventListener(EventConst.EVENT_READYED, onReadyed);
			_operate = tempOperate;
			tempOperate = "";
			var event:EventZheng = new EventZheng(EventConst.EVENT_CHANGEOPERATE);
			event.obj.phase = 3;//完成
			event.obj.type = _operate;
			dispatchEvent(event);
			
		}
		
		public function get operate():String { return _operate; }
		
		public function set operate(value:String):void 
		{
			addEventListener(EventConst.EVENT_READYED, onReadyed);
			var rearlyChangeEvent:EventZheng = new EventZheng(EventConst.EVENT_CHANGEOPERATE);
			rearlyChangeEvent.obj.phase = 2;//准备期
			rearlyChangeEvent.obj.type = _operate;
			tempOperate = value;
			dispatchEvent(rearlyChangeEvent);
			DebugTrace.dtrace("code info MainData.as:现在的操作是:" + _operate);
		}
		
		public function get loginStatus():Boolean { return _loginStatus; }
		
		public function set loginStatus(value:Boolean):void 
		{
			_loginStatus = value;
			var event:EventZheng = new EventZheng(EventConst.EVENT_LOGIN);
			event.obj.login = value;
			dispatchEvent(event);
		}
		
		public function get isMyFarm():Boolean { return _isMyFarm; }
		
		public function set isMyFarm(value:Boolean):void 
		{
			_isMyFarm = value;
		}
		
		public function get putObjType():String { return _putObjType; }
		
		public function set putObjType(value:String):void 
		{
			_putObjType = value;
		}
		
	}
	
}